﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace XDL.Framework.Weapons
{
    /// <summary>
    /// Deserialize binary content into a <see cref="WeaponSettings"/> instance.
    /// </summary>
    public class WeaponSettingsReader : ContentTypeReader<WeaponSettings>
    {
        protected override WeaponSettings Read(ContentReader input, WeaponSettings existingInstance)
        {
            WeaponSettings settings = new WeaponSettings();
            settings.Name = input.ReadString();
            settings.Damage = input.ReadInt32();
            settings.ReloadTime = input.ReadSingle();
            settings.DamageType = input.ReadInt32();
            settings.ContinousFire = input.ReadBoolean();
            settings.RecoilForce = input.ReadSingle();
            settings.Radius = input.ReadSingle();
            settings.FireAnimationDuration = input.ReadObject<TimeSpan>();
            return settings;
        }
    }
}
